/**
 * @author ZCR
 * @create 2025/9/8 21:45
 */
public class Solution645 {
    public int[] findErrorNums(int[] nums) {
        int dup = -1;
        for(int i = 0; i < nums.length; i++){
            int index = Math.abs(nums[i]) -1;
            if(nums[index] < 0){
                dup = Math.abs(nums[i]);
            }else{
                nums[index]*=-1;
            }
        }
        int missing = -1;
        for(int i = 0; i < nums.length; i++){
            if(nums[i]>0){
                missing = i+1;
            }
        }
        return new int[]{dup, missing};
    }
}
